<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-menu.tld" prefix="menu" %>
<%@ taglib uri="/WEB-INF/tlds/struts-menu-el.tld" prefix="menu-el" %>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tlds/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tlds/authz.tld" prefix="authz" %>
<%@ taglib uri="/WEB-INF/tlds/sitemesh-decorator.tld" prefix="decorator"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="request"/>
<script type="text/javascript" src="${ctx}/dwr/interface/FilterServiceDWR.js"></script>
<script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
<script type="text/javascript" src="${ctx}/dwr/util.js"></script>
<script type="text/javascript">
<!--

	function saveFilAttr() {
		var value = $F("value");
		var attr = $F("attribute");
		value = trim(value);
		attr = trim(attr);
		specAttr = unAllowedChars(attr,'<bean:message key="allowedCharacters"/>');
		specVal = unAllowedChars(value,'[()]');
		if(!attr || attr.length == 0) {
			alert('<bean:message key="error.LDAPFieldEmpty" />');
		} else if(!value || value.length == 0) {
			alert('<bean:message key="error.valFieldEmpty" />');
		} else if(specAttr) {
			alert('<bean:message key="error.nameContainsSpecialCharacter"/>');
		} else if(specVal) {
			alert('<bean:message key="error.valContainsBrackets"/>');
		} else {
			filter = { id:"", attribute:"", value:"", ident:"", non:""};
			DWRUtil.getValues(filter);
			FilterServiceDWR.save(refreshAndClose,filter);
		}
	}
	function refreshAndClose() {
		this.opener.location = '${ctx}/filter.do?method=list&amp;decorator=popup&amp;confirm=true';
		closePopup();
	}
// -->
</script>

<div id="subcontent">
	<html:form styleId="filAttrForm" action="/filter" focus="attribute">
		<input type="hidden" id="method" name="method" value=""/>
		<html:hidden property="filter.id" styleId="id"/>
		<p><bean:message key="filterPage.filtAttrDefinition" /></p>
		<p><bean:message key="filterPage.attribute" /> : <html:text property="filter.attribute" styleId="attribute" maxlength="127"/></p>
		<p><bean:message key="filterPage.value" /> :<html:text property="filter.value" maxlength="127" styleId="value"/>
			<html:checkbox property="filter.ident" styleId="ident" />
			<bean:message key="filterPage.id" />
		</p>
		<p><bean:message key="filterPage.not" /> : <html:checkbox property="filter.non" styleId="non" /></p>
		<p>	<input name="validateFilAttrButton" type="submit" value="<bean:message key="filterPage.validate" />" onclick="saveFilAttr();return false;" />&nbsp;
			<input name="cancelFilAttrButton" type="submit" value="<bean:message key="filterPage.cancel" />" onclick="closePopup();" /></p>
	</html:form>
</div>
